<?php

if(!empty($_GET['id'])){
	$id=$_GET['id'];
	$arr=getone('goods','id='.$id);
	$explode=explode(',',$arr['image']);
	foreach ($explode as $key => $value) {
		unlink($value);
	}
$row=delete('goods','id='.$id);
if($row>0){
	echo '<script>alert ("删除成功");location="index.php?admin=1&c=goods&a=list";</script>';
	};
};

if(!empty($_POST)){
	// print_r($_POST);
	// 
	$id=($_POST['id']);
$where=' ';
foreach($id as $key => $value){
	$where.='id='.$value.' or ';
	};
	$where=substr($where,0,-4);
	$arr=getlist('goods',$where);
	
	foreach ($arr as $key => $value) {
		foreach (explode(',',$value['image']) as $k => $val) {
			unlink($val);
		}
	}
$sum=delete('goods',$where);
if($sum>0){
	echo '<script>alert ("删除成功");location="index.php?admin=1&c=goods&a=list";</script>';
	};
}else{
	echo '<script>alert ("请选择要删除的记录");location="index.php?admin=1&c=goods&a=list";</script>';
	};

?>